﻿namespace KinonekoSoftware.CodariaDB.Documents.Shenanigans.Forum
{
    public static class ForumFactory
    {
        public static Discuss CreateDiscuss(string name, string intro, string owner)
        {
            var discuss = new Discuss
            {
                Id      = ID.Get(),
                Name    = name,
                Intro   = intro,
                OwnerID = owner,
                Threads = new List<ForumObject>(),
                Members = new List<string>(),
            };

            return discuss;
        }
        
        public static Discuss CreateDiscuss(Discuss parent, ForumObject thread)
        {
            var name = "";

            if (thread is ImageForumObject ifo)
            {
                name = ifo.Content;
            }
            else if (thread is PlainTextForumObject ptfo)
            {
                name = ptfo.Content;
            }
            else if (thread is ReplyForumObject rfo)
            {
                name = rfo.Content;
            }
            else if (thread is AttachmentForumObject afo)
            {
                name = afo.Content;
            }

            var discuss = new Discuss
            {
                Id      = ID.Get(),
                Name    = name,
                OwnerID = parent.OwnerID,
                Threads = new List<ForumObject>(),
                Members = new List<string>(),
            };

            return discuss;
        }
    }
}